GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 3002d9...0b2563 )
by Florian
01:10
created

Lines.newLine   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
c 1
b 0
f 0
nc 4
nop 2
dl 0
loc 17
rs 8.8571
1
/*jslint
2
  regexp: true
3
  indent: 4
4
*/
5
6
/*global
7
  $,
8
  Cookies, Line, Markers
9
*/
10
11
var Lines = {};
12
Lines.m_map = null;
13
Lines.m_nextLineId = 0;
14
Lines.m_lines = [];
15
16
17
Lines.init = function (themap) {
18
    'use strict';
19
20
    Lines.m_map = themap;
21
    Lines.m_nextLineId = 0;
22
    Lines.m_lines = [];
23
};
24
25
26
Lines.newLine = function (source, target) {
27
    'use strict';
28
29
    var m1 = Markers.getById(source),
30
        m2 = Markers.getById(target);
31
32
    if (!m1 || m1.isFree()) {
33
        source = -1;
34
    }
35
    if (!m2 || m2.isFree()) {
36
        target = -1;
37
    }
38
39
    this.m_lines.push(new Line(Lines.m_map, this.m_nextLineId, source, target));
40
    this.m_nextLineId += 1;
41
    this.saveCookie();
42
};
43
44
45
Lines.getLineIndex = function (id) {
46
    'use strict';
47
48
    var index, line;
49
50
    for (index = 0; index < this.m_lines.length; index += 1) {
51
        line = this.m_lines[index];
52
        if (line && line.getId() === id) {
53
            return index;
54
        }
55
    }
56
57
    return -1;
58
};
59
60
61
Lines.getLineById = function (id) {
62
    'use strict';
63
64
    var index = this.getLineIndex(id);
65
    if (index < 0) {
66
        return null;
67
    }
68
    return this.m_lines[index];
69
};
70
71
72
Lines.getLinesText = function () {
73
    'use strict';
74
75
    var a = [];
76
    this.m_lines.map(function (line) {
77
        if (line) {
78
            a.push(line.getEndpointsString());
79
        }
80
    });
81
    return a.join("*");
82
};
83
84
85
Lines.saveCookie = function () {
86
    'use strict';
87
88
    Cookies.set("lines", this.getLinesText(), {expires: 30});
89
};
90
91
92
Lines.selectLineSourceById = function (id, markerId) {
93
    'use strict';
94
95
    this.getLineById(id).setSource(markerId);
96
    this.saveCookie();
97
};
98
99
100
Lines.selectLineSource = function (id) {
101
    'use strict';
102
103
    var markerId = -1,
104
        opt = $("#dynlinesource" + id + " option:selected");
105
106
    if (opt) {
107
        markerId = parseInt(opt.val(), 10);
108
    }
109
110
    this.selectLineSourceById(id, markerId);
111
};
112
113
114
Lines.selectLineTargetById = function (id, markerId) {
115
    'use strict';
116
117
    this.getLineById(id).setTarget(markerId);
118
    this.saveCookie();
119
};
120
121
122
Lines.selectLineTarget = function (id) {
123
    'use strict';
124
125
    var markerId = -1,
126
        opt = $("#dynlinetarget" + id + " option:selected");
127
128
    if (opt) {
129
        markerId = parseInt(opt.val(), 10);
130
    }
131
132
    this.selectLineTargetById(id, markerId);
133
};
134
135
136
Lines.updateLinesMarkerMoved = function (markerId) {
137
    'use strict';
138
139
    this.m_lines.map(function (line) {
140
        if (line) {
141
            line.updateMarkerMoved(markerId);
142
        }
143
    });
144
};
145
146
147
Lines.updateLinesMarkerAdded = function () {
148
    'use strict';
149
150
    this.m_lines.map(function (line) {
151
        if (line) {
152
            line.updateMarkerAdded();
153
        }
154
    });
155
};
156
157
158
Lines.updateLinesMarkerRemoved = function (markerId) {
159
    'use strict';
160
161
    this.m_lines.map(function (line) {
162
        if (line) {
163
            line.updateMarkerRemoved(markerId);
164
        }
165
    });
166
    this.saveCookie();
167
};
168
169
170
Lines.updateLine = function (id) {
171
    'use strict';
172
173
    var index = this.getLineIndex(id);
174
    if (index < 0) {
175
        return;
176
    }
177
178
    this.m_lines[index].update();
179
};
180
181
182
Lines.deleteLine = function (id) {
183
    'use strict';
184
185
    $('#dynLine' + id).remove();
186
187
    var index = this.getLineIndex(id);
188
    if (index < 0 || !this.m_lines[index]) {
189
        return;
190
    }
191
192
    this.m_lines[index].clearMapObject();
193
    this.m_lines[index] = null;
194
195
    this.saveCookie();
196
};
197
198
199
Lines.deleteAllLines = function () {
200
    'use strict';
201
202
    var self = this;
203
    this.m_lines.map(function (line) {
204
        if (line) {
205
            self.deleteLine(line.getId());
206
        }
207
    });
208
};
209